package com.example.goodog;

import com.example.goodog.items.DogItem;
import com.example.goodog.items.ListItem;
import com.example.goodog.items.ParkItem;
import com.example.goodog.items.StoreItem;
import com.example.goodog.items.UserItem;
import com.google.gson.Gson;

public class ItemFactory {
	
	public static ListItem CreateItem(JsonItem itm, Gson gson)
	{
		Object li = new Object();
		if(itm.JSonType.equals("Dog"))
		{
			li = gson.fromJson(itm.JsonData, DogItem.class);
		}
		else if(itm.JSonType.equals("Store"))
		{
			li = gson.fromJson(itm.JsonData, StoreItem.class);
		}
		else if(itm.JSonType.equals("Park"))
		{
			li = gson.fromJson(itm.JsonData, ParkItem.class);
		}

		((ListItem)li).ImageBlob = itm.Image;
		
		return (ListItem)li;
	}
	
	public static UserItem CreateUserItem(String JsonUser, Gson gson)
	{
		return gson.fromJson(JsonUser, UserItem.class);
		
	}

}
